package com.by.controller;


import com.by.bean.HEnquiry;
import com.by.bean.Offer;
import com.by.common.bean.ResultBean;
import com.by.common.controller.BaseController;
import com.by.service.FreightService;
import com.by.service.HEnquiryService;
import com.by.service.OfferService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "货代询价")
@RequestMapping("/v1")
public class HEnquiryController extends BaseController {
    @Autowired
    HEnquiryService hEnquiryService;
    @Autowired
    OfferService offerService;
    @Autowired
    FreightService freightService;

    @ApiOperation("保存询价单")
    @PostMapping("/HEnquiry/save")
    public ResultBean save(@RequestBody HEnquiry hEnquiry){
        int rs=hEnquiryService.insert(hEnquiry);
        return saveResult(rs);
    }
    @ApiOperation("保存报价单")
    @PostMapping("/Offer/save")
    public ResultBean save(@RequestBody Offer offer) {
        offer.setName(freightService.selectName(offer.getUserId()));
        System.out.println(offer.getName()+" "+offer.getUserId());
        int res = offerService.save(offer);
        return saveResult(res);
    }
}
